layui.use(["layer", "form", "laydate", "laypage"], function () {
    var $ = layui.jquery, layer = layui.layer, form = layui.form, laydate = layui.laydate, laypage = layui.laypage;
    form.on("select(userType)", function (data) {
        var val = data.value;
        $(".layui-form").eq(0).submit();
    });
    var ss=$("input[name='uty']").val();
    if ("0" == ss) {
        $("input[name='date']").parent(".layui-inline").show();
        $("input[name='date1']").parent(".layui-inline").hide();
    } else {
        $("input[name='date']").parent(".layui-inline").hide();
        $("input[name='date1']").parent(".layui-inline").show();
    }
    form.on("select(dateType)", function (data) {
        var val = data.value;
        if ("0" == val) {
            $("input[name='date']").parent(".layui-inline").show();
            $("input[name='date1']").parent(".layui-inline").hide();
        } else {
            $("input[name='date']").parent(".layui-inline").hide();
            $("input[name='date1']").parent(".layui-inline").show();
        }
    });
    form.on("radio(info)",function (data) {
        $(".layui-form").eq(0).submit();
    });
    laydate.render({
        elem: '#date'
        , type: 'month'
        , format: "yyyy/MM"
    });
    laydate.render({
        elem: '#date1'
        , format: "yyyy/MM/dd"
    });
    var count1 = $("input[name='totalPages1']").val();
    var count2 = $("input[name='totalPages2']").val();
    $(".layui-btn").on("click", function () {
        $(".layui-form").eq(0).submit();
    });
    laypage.render({
        elem: 'pager1'
        , count: parseInt(count1)
        , curr: parseInt($("input[name='page1']").val())
        , limit: 11
        , theme: '#1E9FFF'
        , groups: 2
        , jump: function (obj, first) {
            $("input[name='page1']").val(obj.curr);
            if (!first) {
                $(".layui-form").eq(0).submit();
            }
        }
    });
    laypage.render({
        elem: 'pager2'
        , count: parseInt(count2)
        , curr: parseInt($("input[name='page2']").val())
        , limit: 11
        , theme: '#1E9FFF'
        , groups: 2
        , jump: function (obj, first) {
            $("input[name='page2']").val(obj.curr);
            if (!first) {
                $(".layui-form").eq(0).submit();
            }
        }
    });
    $(".custom-user").on("click", function () {
        var val = $(this).attr("content");
        $("input[name='user']").val(val);
        $(".layui-form").eq(0).submit();
    });
    $(".custom-open").off("click").on("click", function () {
        var id = $(this).attr("content");
        layer.open({
            title: "日程详情",
            type: 2,
            area: ['80%', '80%'],
            fixed: true, //不固定
            maxmin: true,
            content: '/uc/user/'+id+'/entity'
        });
    });
});